package cn.zpro.lazycat.codegen;

import cn.zpro.lazycat.codegen.core.Configeration;
import cn.zpro.lazycat.codegen.core.GenService;

/**
 * 代码生成器初始化类
 */
public class Application {

    public static void main(String[] args) throws Exception {
//        codeGen("ProjectExt", "bmpfjz_project_ext");
//        codeGen("ChafferRecord", "bmpfjz_chaffer_record");
//        codeGen("Faq", "bmpfjz_faq");
//        codeGen("Project", "bmpfjz_project");
//        codeGen("ProjectFile", "bmpfjz_project_file");
//        codeGen("ProjectItem", "bmpfjz_project_item");
//        codeGen("SupplierBidFile", "bmpfjz_supplier_bid_file");
//        codeGen("SupplierBidModifyLog", "bmpfjz_supplier_bid_modify_log");
//        codeGen("SupplierProjectBid", "bmpfjz_supplier_project_bid");
//        codeGen("ProjectChangeHistory", "bmpfjz_project_change_history");
        codeGen("SupplierProjectItemBid", "bmpfjz_supplier_project_item_bid");


    }

    /**
     * 生成器
     *
     * @param objName   实体名称例如（Faq）
     * @param tableName 生成的表名称（bmpfjz_faq）
     */
    public static void codeGen(String objName, String tableName) {
        String rootPath = "E:\\idea_work_spaces\\cooperate\\purchase\\purchase-dal\\";

        String interfacePath = rootPath + "purchase-service\\src\\main\\java\\cn\\bidlink\\cooperate\\purchase\\server\\";
        String mapperPath = rootPath + "purchase-impl\\src\\main\\resources";
        String testPath = rootPath + "purchase-impl\\src\\test\\java\\cn\\bidlink\\cooperate\\purchase\\server\\test\\";
        String entityPath = rootPath + "purchase-entity\\src\\main\\java\\cn\\bidlink\\cooperate\\purchase\\server\\entity\\";

        String implPath = rootPath + "purchase-impl\\src\\main\\java\\cn\\bidlink\\cooperate\\purchase\\server\\";

        Configeration configeration = new Configeration();
        GenService genService = new GenService();
        configeration.setTableName(tableName);/*表名称*/
        configeration.setDaoName(objName + "Dao");/*DAO名称*/
        configeration.setModelName(objName);/*实体类名称*/
        configeration.setDubboServiceImplName("Dubbo" + objName + "ServiceImpl");/*Dubbo服务的实现类名称*/
        configeration.setDubboServiceName("Dubbo" + objName + "Service");/*Dubbo接口名称*/
        configeration.setPackageName("cn.bidlink.cooperate.purchase.server");/*默认包名称*/
        configeration.setAuthor("<a href=\"mailto:guolongzhang@ebnew.com\">张国龙</a>");/*作者*/
        genService.setConfigeration(configeration);

        /*生成Mybatis代码*/
        genService.genXml(mapperPath + "\\sql-mapper\\" + objName + "Mapper.xml");
        //genService.genDao(implPath + "dao\\" + objName + "Dao.java");
        genService.genModel(entityPath + objName + ".java");
        /*生成配置Mybatis-config文件*/
        //genService.genSpringConfig("F:\\gen\\spring-config.xml");
        /*生成Dubbo代码和单元测试代码*/
        //genService.genDubboService(interfacePath + "service\\Dubbo" + objName + "Service.java");
        //genService.genDubboServiceImpl(implPath + "service\\impl\\Dubbo" + objName + "ServiceImpl.java");
        //genService.genTestDubboService(testPath + "TestDubbo" + objName + "Service.java");
    }

}
